﻿using Sunny.UI;
using System.Data;

namespace Ycjw.PipeLine.Map.Basic.Results
{
    public class ResultWindowWithPieChart : ResultWindowWithChart
    {
        protected override void AddOptionSeries(DataTable dt)
        {
            foreach (DataRow dr in dt.Rows)
            {
                var series = new UIPieSeries
                {
                    Name = dr[0].ToString()
                };
                for (int i = 1; i < dr.ItemArray.Length; i++)
                {
                    double.TryParse(dr[i].ToString(), out double val);
                    series.AddData(dt.Columns[i].Caption, val);
                }
                ((UIPieOption)m_UIOption).AddSeries(series);
            }
        }

        protected override void SetLegendItem(DataTable dt)
        {
            foreach (DataColumn dc in dt.Columns)
            {
                if (dt.Columns.IndexOf(dc) == 0) continue;
                ((UIPieOption)m_UIOption).Legend.AddData(dc.Caption);
            }
        }
        protected override void CreateChart()
        {
            this.m_UIChart = new UIPieChart();
            m_UIOption = new UIPieOption();
        }
        protected override void SetOptionEx()
        {
        }
    }
}
